package com.helloUIBinder.client.receivers;

import com.google.gwt.http.client.RequestBuilder;
import com.google.gwt.http.client.RequestCallback;
import com.google.gwt.http.client.RequestException;

public class SecurityContextHolderReceiver {

    private final static String SECURITY_CONTEXT_HOLDER_URL = "/rest/securityContextHolderService/"; //if you add string, it will be a message to web-service
    private final static String USERNAME = "username";

    public static void getCurrentUserLogin(RequestCallback requestCallback) {
        try {
            RequestBuilder blogPostRequestBuilder = new RequestBuilder(RequestBuilder.GET, SECURITY_CONTEXT_HOLDER_URL + USERNAME);
            blogPostRequestBuilder.setCallback(requestCallback);
            blogPostRequestBuilder.send();
        } catch (RequestException rEx) {
            rEx.printStackTrace();
        }
    }
}
